package com.houweishi.module.record.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.houweishi.common.annotation.Excel;
import com.houweishi.common.core.domain.BaseEntity;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;

import java.time.LocalDate;

/**
 * 审批信息记录对象 biz_approval_record
 * 
 * @author houweishi
 * @date 2023-02-21
 */
@Data
public class BizApprovalRecord extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 自增id */
    private Long id;

    /** 类型表id */
    private Long typeId;

    /** 申请表id */
    private Long applicationId;

    /** 用户id */
    private Long userId;

    /** 用户名 */
    @Excel(name = "用户名")
    private String username;

    /** 审批人id(user_id) */
    private Long approverId;

    /** 审批人姓名(username) */
    @Excel(name = "审批人姓名")
    private String approverName;

    /** 审批状态（1同意，2驳回） */
    @Excel(name = "审批状态", readConverterExp = "1=同意，2驳回")
    private String approvalStatus;

    /** 审批时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "审批时间", width = 30, dateFormat = "yyyy-MM-dd")
    private LocalDate approvalTime;

    /** 审批备注 */
    @Excel(name = "审批备注")
    private String approvalRemark;

    /** 删除标志（0代表存在 2代表删除） */
    private String delFlag;


    /** 申请表类型id */
    private Long subscribePatternId;

    /** 申请表类型名称 */
    @Excel(name = "申请表类型名称")
    private String subscribePatternName;

    /** 职位等级 */
    @Excel(name = "职位等级")
    private Long positionLevel;
    /** 流水单号 */
    @Excel(name = "流水单号")
    private String serialNum;

    /** 审批顺序 */
    @Excel(name = "审批顺序")
    private Integer sequence;

    /** 操作类型 */
    @Excel(name = "操作类型",readConverterExp = "agree=同意，reject=驳回")
    private String typeOperation;

    /** 延时备注 */
    @Excel(name = "延时备注")
    private String deferredRemark;

    /** 业务表状态 */
    @Excel(name = "业务表状态")
    private String businessStatus;

    /**
     * 追加审批人
     */
    private String appendApprovedUserIds;

    public BizApprovalRecord() {
    }

    public BizApprovalRecord(Long approverId, String approvalStatus, String serialNum) {
        this.approverId = approverId;
        this.approvalStatus = approvalStatus;
        this.serialNum = serialNum;
    }

    public BizApprovalRecord(String serialNum, Integer sequence) {
        this.serialNum = serialNum;
        this.sequence = sequence;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this)
                .append("id", id)
                .append("typeId", typeId)
                .append("applicationId", applicationId)
                .append("userId", userId)
                .append("username", username)
                .append("approverId", approverId)
                .append("approverName", approverName)
                .append("approvalStatus", approvalStatus)
                .append("approvalTime", approvalTime)
                .append("approvalRemark", approvalRemark)
                .append("delFlag", delFlag)
                .append("subscribePatternId", subscribePatternId)
                .append("subscribePatternName", subscribePatternName)
                .append("positionLevel", positionLevel)
                .append("serialNum", serialNum)
                .append("sequence", sequence)
                .append("typeOperation", typeOperation)
                .append("deferredRemark", deferredRemark)
                .append("businessStatus", businessStatus)
                .toString();
    }
}
